/*
 * Copyright (c) 2018. 国脉海洋信息发展有限公司
 */

package com.gov.dna.base.controller;


import com.gov.dna.base.entity.BaseNode;
import com.gov.dna.base.mybatis.BasePage;
import com.gov.dna.base.service.BaseNodeService;
import com.gov.dna.common.util.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * 通用树形controller
 * @author (作者) Dong Jie 154046519@qq.com
 * @version V1.0
 * @date 2019/1/6 21:04
 * @since (该版本支持的JDK版本) 1.8
 */
public class BaseNodeController<M extends BaseNodeService<T>,T extends BaseNode> extends BaseController<M,T>{

    @GetMapping("/tree")
    @ApiOperation(value = "通用返回所有数据 树形结构", notes = "通用返回所有数据 树形结构", httpMethod = "GET")
    public R tree(T o) throws IllegalAccessException, InstantiationException {
        return new R(baseService.buildTree(o));
    }

    @GetMapping("/lazyTree")
    @ApiOperation(value = "通用返回分页数据 懒加载树形结构", notes = "通用返回分页数据 懒加载树形结构", httpMethod = "GET")
    public R lazyTree(T o,BasePage<T> page) throws IllegalAccessException, InstantiationException {
        return new R(baseService.buildLazyTree(o,page));
    }
}
